home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Unreal Tournament Game Programming for Teens
/
UnrealTournamentGameProgrammingForTeens.iso
/
Chapter Files
/
Chapter09
/
DiscoBallB.txt
< prev
next >
Wrap
Text File
|
2006-11-01
|
2KB
|
90 lines
//======================================================================
// DiscoBallB
// DiscoBallB.txt
//======================================================================
// #1
class DiscoBallB extends KActor placeable;
var private int Next;
var private float TimerD;
enum SIDES{
TOP,
LEFT,
BOTTOM,
RIGHT
};
const PATHS = 4;
var Vector Square[PATHS];
// #2
function PreBeginPlay() {
// Called once to set initial values
SetTimeD(9.0);
// From the KActor class
SetTimer(TimerD, true);
// Set for this class
Next = 0;
}
// #3
private function CreatePaths(){
Square[SIDES.TOP] = vect(40.0 ,0, 0);
Square[SIDES.LEFT] = vect(0, 0, -40.0);
Square[SIDES.BOTTOM] = vect(-40.0 ,0, 0);
Square[SIDES.RIGHT] = vect(0, 0, 40.0);
}
// Accessor for the array
private function Vector GetPath(SIDES path){
return Square[path];
}
function PostBeginPlay() {
Velocity = vect(0 , 0, 0);
CreatePaths();
}
// #4
function Timer() {
ChangePath();
}
// #5
// Sets initial values for the time durations
// Call once to set the inital state of the class
private function SetTimeD(float dur){
if(dur < 0){
dur = 0;
}
TimerD = dur;
}
// #6
// Creates a "square" path for the object
private function ChangePath(){
if(Next == SIDES.TOP){
// positive x direction
Velocity = GetPath(SIDES.TOP);
Next++;
}else if(Next == SIDES.LEFT){
// negative z direction
Velocity = GetPath(SIDES.LEFT);
Next++;
}else if(Next == SIDES.BOTTOM){
// negative x direction
Velocity = GetPath(SIDES.BOTTOM);
Next++;
}else if (Next == SIDES.RIGHT){
// posivite z direction
Velocity = GetPath(SIDES.RIGHT);
Next = SIDES.TOP;
}else{
Next = SIDES.TOP;
}
}